package com.google.rui.demos.apn;

/**
 * 
 * @author wuzhu �Ĵ���� 2010.10
 * �й�jͨ3GWAP����        �й�jͨ3G����������        �й�jͨWAP����        �й�jͨ����������		�й����WAP		�й����NET
 * 3gwap                 3gnet                uniwap            uninet					ctwap			ctnet
 */
public class ApnMatchTools {
	public static class ApnNet{ 
		
		/**
		 * �й��ƶ�������
		 */
		public static String[] CMNumeric={"46000","46002","46007"};
		
        /**   
         * �й��ƶ�cmwap   
         */   
        public static String CMWAP = "cmwap";    
            
        /**   
         * �й��ƶ�cmnet   
         */   
        public static String CMNET = "cmnet";  
            
        /**
         * �й�jͨ������
         */
        public static String[] UNINumeric={"46001"};
            
        /**   
         * 3G wap �й�jͨ3gwap APN    
         */   
        public static String GWAP_3 = "3gwap";    
            
        /**   
         * 3G net �й�jͨ3gnet APN    
         */   
        public static String GNET_3="3gnet";    
            
        /**   
         * uni wap �й�jͨuni wap APN    
         */   
        public static String UNIWAP="uniwap";    
        /**   
         * uni net �й�jͨuni net APN    
         */   
        public static String UNINET="uninet";
        
        /**
         * �й����������
         */
        public static String[] CTNumeric={"46003"};
            
        /**   
         * �й����Wap APN    
         */   
        public static String CTWAP = "ctwap";    
            
        /**   
         * �й����net APN    
         */   
        public static String CTNET="ctnet";   
    }    
   
	/**
	 * ��ȡ������������
	 * @param apn
	 * @return
	 */
	public static String MatchApn(ApnNode apn)
	{
		for(String str:ApnNet.CTNumeric)
			if(str.equals(apn.getNumeric()))
				return MatchApn(apn.getApn());
		for(String str:ApnNet.UNINumeric)
			if(str.equals(apn.getNumeric()))
				return MatchApn(apn.getApn());
		for(String str:ApnNet.CTNumeric)
			if(str.equals(apn.getNumeric()))
				return MatchApn(apn.getUser());
		return MatchApn(apn.getApn());
	}
   
   /**
    * ��ȡ������������
    * @param currentName
    * @return
    */
    public static String MatchApn(String currentName) {            
        if("".equals(currentName) || null==currentName){    
            return "";    
        }    
        currentName = currentName.toLowerCase();    
        if(currentName.startsWith(ApnNet.CMNET))    
            return ApnNet.CMNET;    
        else if(currentName.startsWith(ApnNet.CMWAP))    
            return ApnNet.CMWAP;    
        else if(currentName.startsWith(ApnNet.GNET_3))    
            return ApnNet.GNET_3;    
        else if(currentName.startsWith(ApnNet.GWAP_3))    
            return ApnNet.GWAP_3;    
        else if(currentName.startsWith(ApnNet.UNINET))    
            return ApnNet.UNINET;    
        else if(currentName.startsWith(ApnNet.UNIWAP))    
            return ApnNet.UNIWAP;
        else if(currentName.startsWith(ApnNet.CTNET))
        	return ApnNet.CTNET;
        else if(currentName.startsWith(ApnNet.CTWAP))
        	return ApnNet.CTWAP;
        
        else if(currentName.startsWith("default"))    
            return "default";    
        else return "";    
       // return currentName.substring(0, currentName.length() - SUFFIX.length());    
    }    

}
